<?php
use yii\helpers\Url;
use yii\bootstrap\ActiveForm;
?>
<form action="?r=took/index2" method="post">
    <div class="form-group">
        <label for="exampleInputEmail1">用户名</label>
        <input type="string" class="form-control" name="t_name" id="exampleInputEmail1" placeholder="name">
    </div>
    <div class="form-group">
        <label for="exampleInputPassword1">密码</label>
        <input type="password" class="form-control" name="t_pwd"  id="pw" placeholder="Password" onblur="fun1()">
    </div>
    <div class="form-group">
        <label for="exampleInputPassword1">电话</label>
        <input type="string" class="form-control" name="t_tell"  id="tel" placeholder="tell" onblur="fun2()">
    </div>
    <div class="form-group">
        <label for="exampleInputPassword1">邮箱</label>
        <input type="email" class="form-control" name="t_email"  id="exampleInputPassword1" placeholder="email">
    </div>

    <input type="hidden" name="_csrf" value="<?php echo Yii::$app->request->csrfToken ?>">

    <button type="submit" class="btn btn-default">Submit</button>
</form>

<script>
    function fun1()//验证密码6位以上
    {
        var pw=document.getElementById('pw').value
        var aaa=/^\w{6,}$/
        if(aaa.test(pw))
        {
            alert('没有问题');
        }
        else
        {
            alert('有问题');
        }
    }

    function fun2()//验证手机号
    {
        var tel = document.getElementById('tel').value
        var reg = /^1[358]\d{9,}$/
        if (reg.test(tel))
        {
            alert('摸问题');
        }
        else {
            alert('呦问题');
        }
    }

</script>